package blog.sys.service;

import blog.sys.data.release.ReleaseContentInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pub.dao.GeneralDao;
import pub.dao.jdbc.ListQuery;
import pub.dao.query.Query;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class FindService {

    public List<ReleaseContentInfo> onGetReleaseContentService() {
        Query<ReleaseContentInfo> query = ListQuery.of(ReleaseContentInfo.class);
        String sql = "SELECT r.*, u.nickname FROM t_release_content r LEFT JOIN t_user u on u.id = r.user_id WHERE  r.status = 1 order by id desc";
        query.setSql(sql);
        generalDao.execute(query);
        List<ReleaseContentInfo> contents = query.getResult().getRows();
        return contents;
    }

    @Autowired
    private GeneralDao generalDao;

}
